fix: remove immer from watch event batching - #49
Conversation
…ce errors Wails v3 bindings return class instances (e.g. ListResult) which Immer cannot draft, causing "produce can only be called on draftable things" errors on every watch event flush. Replace produce() with manual immutable updates (shallow array copy + spread) in useEventBatcher and useWatchState. This also removes Immer's proxy wrapping and deep-freeze overhead on the hot path.
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughRemoved Immer dependency from event batching and watch state management. Replaced Immer's Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/omniviewdev-runtime/src/hooks/resource/useWatchState.ts`:
- Around line 44-56: The updater currently recomputes resources, resourceCounts,
syncedCount, and errorCount but leaves totalResources stale by spreading ...old;
update the returned object to set totalResources to the current number of
resource keys (e.g., Object.keys(resources).length) so
WatchConnectionSummary.totalResources reflects the new resources map; locate the
updater in useWatchState.ts where resources is built and include totalResources
alongside resources, resourceCounts, syncedCount, and errorCount in the returned
object.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 3a9420e6-a150-41e6-9158-5cf8c2fe4c2a
📒 Files selected for processing (3)
packages/omniviewdev-runtime/src/hooks/resource/useEventBatcher.test.tspackages/omniviewdev-runtime/src/hooks/resource/useEventBatcher.tspackages/omniviewdev-runtime/src/hooks/resource/useWatchState.ts
totalResources was inherited from the old state via spread, so it became stale when a new resource key arrived via a watch event. This affected polling decisions, isFullySynced, and syncProgress.
Summary
ListResult) that Immer cannot draft, causingproduce can only be called on draftable thingserrors on every watch event flushproduce()with manual immutable updates (shallow array copy + spread) inuseEventBatcheranduseWatchStateTest plan
useEventBatchertestsSummary by CodeRabbit
Tests
Refactor